<?php
#                                                                                 
# author: Cody Sorgenfrey                                       
# (c)2013 South Hill Calvary Chapel                                               
# 
$event = mysql_fetch_array(mysql_query("SELECT * FROM `events` WHERE `id`='$id'"));
printf("<script type='text/javascript'>document.cookie = \"vars=%s_%s_%s\";</script>", $event['costPerPerson'], $event['costPerCouple'], $event['maxCost']); 
include_once("registrationManagerFunctions.php"); 
printf('<input type="hidden" id="itemName" name="item_name" value="%s Registration">', $title);
printf('<input type="hidden" id="itemNumber" name="item_number" value="shcc-%s">', $id);
printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/registrationManager.js'></script>");                                
?>
<style type="text/css">
	input[type="text"]
	{
		width:48%;
		max-width: 200px;
	}
	textarea
	{
		margin-top: -15px;
	}
</style>
<script type="text/javascript">
	var defer = 0;
	function golfPrepSubmit(id)
	{	
		for (var x=0;x<registration.numberRegistered;x++){
			registration.people[x] = document.getElementsByName(registration.formNumber+"-firstNames")[x].value;
			registration.people[x] += " " + document.getElementsByName(registration.formNumber+"-lastNames")[x].value;
		}
		if (document.getElementById(registration.formNumber+"-teamName").value != ""){
			registration.notes = document.getElementById(registration.formNumber+"-teamName").value + ", ";
		} else {
			alert("Must provide a team name.");
			return 0;
		}
		if ((document.getElementById(registration.formNumber+"-notes").value !="")){
			registration.notes += document.getElementById(registration.formNumber+"-notes").value;
		} 
		validateEmail(document.getElementById(registration.formNumber+"-email"));
		if (defer){
			registration.paymentType="Hasn't Paid";
			updateRegPrice(registration.numberRegistered);
			registration.paidInFull = 0;
			registration.amountOwe = parseFloat(registration.amountDue);
			registration.amountDue = 0.00;
		} 
		registration.checkOut = 0;
		customSubmit(id);
	}
	function updateForm(obj) 
	{	
		if (obj.options[obj.selectedIndex].text == "Team"){
			registration.originalFirstName.placeholder = "Leader First Name";
			registration.originalLastName.placeholder = "Leader Last Name";
			if (registration.extraFields.childNodes.length == 0){
				addMore();
				addMore();
				addMore();
			}
		} else if (obj.options[obj.selectedIndex].text == "Individual"){
			registration.originalFirstName.placeholder = "First Name";
			registration.originalLastName.placeholder = "Last Name";
			registration.extraFields.innerHTML = "";
		} else if (obj.options[obj.selectedIndex].text == "Paypal"){
			defer = 0;
		} else if (obj.options[obj.selectedIndex].text == "Cash or check later"){
			defer = 1;
		}
	}
	function showSponsershipForm()
	{
		var form = document.getElementById("sponsership");
		if (form.style.display == "none"){
			form.style.display = "block";
		} else {
			form.style.display = "none";
		}
	}
	function updateSponAmount(obj)
	{
		if (document.getElementById("S-defer").options[document.getElementById("S-defer").selectedIndex].value == "1"){
			document.getElementById("S-amountDue").value = (obj.value);
		} else {
			document.getElementById("S-amountDue").value = (parseFloat(obj.value)+((parseFloat(obj.value)*.023)+.30)).toFixed(2);
		}
	}
	function returnCheckedRadio()
	{
		radios = document.getElementsByName("Stype");
		for (var i=0;i<radios.length;i++){
			if (radios[i].checked){
				return radios[i];
			}
		}
	}
	function submitSponsorship(id)
	{
		registration = newRegistration("S");
		registration.people[0] = document.getElementById("S-firstNames").value+" "+document.getElementById("S-lastNames").value;
		registration.donation = parseFloat(document.getElementById("S-amountDue").value);
		registration.email = document.getElementById("S-email").value;
		registration.phone = document.getElementById("S-area").value+"."+document.getElementById("S-pre").value+"."+document.getElementById("S-post").value;
		registration.notes = "Donation Only\r\rCompany Info:\rName: "+document.getElementById("S-buisness").value+"\rEmail: "+document.getElementById("SB-email").value+"\rPhone: "+document.getElementById("SB-area").value+"."+document.getElementById("SB-pre").value+"."+document.getElementById("SB-post").value+"\r\rSponsor Comments: "+document.getElementById("S-notes").value;
		registration.paymentType = "Paypal";
		registration.checkOut = 0;
		registration.paidInFull = 1;
		registration.newRegistration = 1;
		registration.amountDue = registration.donation;
		if (document.getElementById("S-defer").options[document.getElementById("S-defer").selectedIndex].value == "1"){
			registration.amountOwe = parseFloat(registration.donation);
			registration.paymentType = "Hasn't Paid";
			registration.paidInFull = 0;
			registration.donation = 0;
			registration.amountDue = 0;
		}
		customSubmit(id);
	}
</script>
<form>
<p>Please fill out the form below to register for the Golf Tournament. Teams are allowed to have 4 people max. If you are registering as an individual, but are part of a team, please put your team's name in the box labeled "Team Name". Mulligans will be available at the course before the event and on select Sundays in the foyer, for $5 each. To register online there is a small processing fee reflected in your total.</p>
<select onchange="updateForm(this);">
	<option>Individual</option>
	<option>Team</option>
</select><br><br>
<input type='text' id='0-firstNames' name='0-firstNames' placeholder='First Name' onkeyup='countPeople();'>
<input type='text' id='0-lastNames' name='0-lastNames' placeholder='Last Name'><br>
<div id='0-people' style='max-width:300px;'></div><br>
<input type='text' id='0-email' style='width:200px' onkeyup='validateEmail(this)' placeholder='Email'><br>
<span style='color:red;' id='0-email'></span><br>
Phone: <input type='text' maxlength='3' style='width:30px;' id='0-area' onkeyup='autoTab(this)'>
- <input type='text' maxlength='3' style='width:30px;' id='0-pre' onkeyup='autoTab(this)'>
- <input type='text' maxlength='4' style='width:40px;' id='0-post' onkeyup='registerPhone(this)'><br><br>
Amount Due: $<input type='text' id ='0-amountDue' name='amountDue' value='0.00' disabled='true'><br><br>
<select onchange="updateForm(this);">
	<option name="Team">Paypal</option>
	<option name="Indi" select="selected">Cash or check later</option>
</select><br><br>
<input type='hidden' name='0-paymentType' value='Paypal'>
<input type='hidden' id='0-scholarship'>
<input type="text" id="0-teamName" placeholder="Team Name"><br>
<h6>Comments...</h6>
<textarea id='0-notes' style='width:98%;height:98%;max-width:98%;'></textarea><br><br>
</form>                    
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
<?
printf('<input type="submit" border="0" value="Register" alt="PayPal - The safer, easier way to pay online!" onclick="golfPrepSubmit(\'%s\')">', $id);
?>
</div>
<div style="">
<a  style='cursor:pointer;' onclick='showSponsershipForm()'><h4 id='displayForm'>Sponser Event</h4></a>
<div id='sponsership' style='display:none;' class='paragraph'><br>
Fill out the following form to sponsor the 2013 Golf Tournament. Benefits from the event go to "House of Blessing" orphanage. Company information provided will be used for signs and promotional materials. For more information check out the <a href="/images/flyer/2013GolfDonorLetter.pdf" target="_blank">[Donor Letter]</a>.<br><br
<form>
<input type='text' id='S-buisness' name='S-buisness' placeholder='Company Name' onkeyup=''><br>
<input type='text' id='SB-email' style='width:200px' onkeyup='validateEmail(this)' placeholder='Company Email'>
<span style='color:red;' id='SB-emailError'></span><br>
Company Phone: <input type='text' maxlength='3' style='width:30px;' id='SB-area' onkeyup='autoTab(this)'>
- <input type='text' maxlength='3' style='width:30px;' id='SB-pre' onkeyup='autoTab(this)'>
- <input type='text' maxlength='4' style='width:40px;' id='SB-post' onkeyup='registerPhone(this)'>
<br><br>

<input type='text' id='S-firstNames' name='S-firstNames' placeholder='Your First Name' onkeyup=''>
<input type='text' id='S-lastNames' name='S-lastNames' placeholder='Your Last Name'><br>
<input type='text' id='S-email' style='width:200px' onkeyup='validateEmail(this)' placeholder='Your Email'>
<span style='color:red;' id='S-emailError'></span><br>
Your Phone: <input type='text' maxlength='3' style='width:30px;' id='S-area' onkeyup='autoTab(this)'>
- <input type='text' maxlength='3' style='width:30px;' id='S-pre' onkeyup='autoTab(this)'>
- <input type='text' maxlength='4' style='width:40px;' id='S-post' onkeyup='registerPhone(this)'><br><br>

<select id="Stype" onchange="updateSponAmount(this.options[this.selectedIndex])">
<option value="0.00">Choose Sponsorship Type...</option>
<option value="500.00">Platinum Sponsor ($500)</option>
<option value="250.00">Gold Sponsor ($250)</option>
<option value="200.00">Silver Sponsor ($200)</option>
<option value="150.00">Bronze Sponsor ($150)</option>
<option value="100.00">Individual Hole Sponsor ($100)</option>
</select><br><br>
Amount Due: $<input type='text' id ='S-amountDue' name='amountDue' value='0.00' disabled='true'><br>
<select id="S-defer" onchange="updateSponAmount(document.getElementById('Stype').options[document.getElementById('Stype').selectedIndex])">
	<option value="0">Paypal</option>
	<option value="1">Cash or check later</option>
</select><br>
<input type='hidden' name='S-paymentType' value='Paypal'>
<h6>Comments...</h6>
<textarea id='S-notes' style='width:98%;max-width:98%;'></textarea><br><br>
</form>                    
<?
printf('<input type="submit" border="0" value="Submit" alt="PayPal - The safer, easier way to pay online!" onclick="submitSponsorship(%s);">', $id);
?>
</div>